/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rpg.gameSkeleton;

import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JRootPane;
import rpg.GameCharacter;
import rpg.PlayerCharacter;

/**
 *
 * @author Emmanouil Samatas
 */
public class BattleFrame extends JFrame implements BattleObserver {
    private List<BattleObserver> battleObserverList = new ArrayList<>();
    public BattleFrame(PlayerCharacter myHero){
        BattleBoard panel = new BattleBoard(myHero);
        
        panel.registerToBattleObserver(this);
        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        getContentPane().add(panel);
        pack();
        setVisible(true);
        setResizable(false);
        
        
    }
    
    
    //test
    public static void main(String[] args){
        PlayerCharacter pc = new PlayerCharacter();
        BattleFrame bf = new BattleFrame(pc);
    }

    void registerToBattleObserver(BattleObserver bo) {
        battleObserverList.add(bo);
    }

    @Override
    public void battleBegins() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void battleEnded(boolean playerWon) {
        this.dispose();
        for(BattleObserver bo : battleObserverList){
            bo.battleEnded(playerWon);
        }
       
    }
    
}
